const db = require('../config/db');
const Sequelize = db.sequelize;
const UserInfo = Sequelize.import('../schema/home');

// force参数，每次重新启动项目时会删除表重新创建；
UserInfo.sync({force: false}); 

class UserInfoModel {
    // 获取全部数据
    static async getAllInfo() {
        let res = await UserInfo.findAll();
        return res;
    }

    // 提交表单数据
    static async postInfo(data) {
        return await UserInfo.create({
            name: data.name,
            gender: data.gender,
            working_years: data.working_years,
            position: data.position,
            per_eval: data.per_eval,
        })
    }

}

module.exports = UserInfoModel;
